<!DOCTYPE html>
<html>
<head>
    <title>SRS</title>
    <meta charset="utf-8">
    <style>
        body{
            padding-top: 30px;
        }
    </style>
    <link rel="stylesheet" type="text/css" href="/static/player/css/bootstrap.min.css"/>
    <script type="text/javascript" src="/static/player/js/jquery-1.10.2.min.js"></script>
    <script type="text/javascript" src="/static/player/js/adapter-7.4.0.min.js"></script>
    <script type="text/javascript" src="/static/player/js/srs.sdk.js"></script>
    <script type="text/javascript" src="/static/player/js/winlin.utility.js"></script>
    <script type="text/javascript" src="/static/player/js/srs.page.js"></script>
</head>
<body>

    <img src='https://ossrs.net/gif/v1/sls.gif?site=ossrs.net&path=/player/rtcpublisher'/>
    <div class="navbar navbar-fixed-top">
        <div class="navbar-inner">
            <div class="container">
                <a id="srs_index" class="brand" href="/">SRS</a>
                <div class="nav-collapse collapse">
                    <ul class="nav">
                        <li class="active"><a id="nav_srs_player" href="/admin/live/webSrsLives">SRS直播间</a></li>

                        <li>
                            <a href="https://github.com/ossrs/srs">
                                <img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/ossrs/srs?style=social">
                            </a>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
    <div class="container">
        <div style="min-height: 500px;">
            <div>
                <button id="show_add_live">添加直播</button>
            </div>
            <div>
                <span>序号</span>
                <span>用户ID</span>
                <span>直播编号</span>
                <span>直播路径</span>
                <span>RTC地址</span>
                <span>RTMP地址</span>
                <span>下单地址</span>
                <span>更新时间</span>
                <span>操作</span>

            </div>
 
            <div class="form-inline" th:each="live : ${lives}">
                <span th:text="${live.id}"></span>
                <span th:text="${live.uid}"></span>
                <span th:text="${live.liveno}"></span>
                <span th:text="${live.liveno}"></span>
                <span th:text="${live.rtcUrl}"></span>
                <span th:text="${live.rtmpUrl}"></span>
                <span th:text="${live.downUrl}"></span>
                <span th:text="${live.updateTime}"></span>
                <span>
                    <a th:href="'/admin/live/webSrsPush?id=' + ${live.id}">推流</a>
                    <a th:href="'/admin/live/webSrsPlay?id=' + ${live.id}">rtc观看</a>
                    <a th:href="'/admin/live/webSrsRtmp?id=' + ${live.id}">rtmp观看</a>
                    <a th:href="'/admin/live/webSrsStop?id=' + ${live.id}">停播</a>
                </span>

            </div>
 

            <div id="live_add_container" style="display:none">
                <label>
                    编号：
                    <input type="text" name="path" value="" id="live_liveno" />
                </label>
                <label>
                    路径：
                    <input type="text" name="path" value="" id="live_path" />
                </label>
                <button id="add_live_btn">添加</button>
            </div>
        </div>

        <footer>
            <p></p>
            <p style="text-align:center"><a href="https://github.com/ossrs/srs">SRS Team &copy; 2020</a></p>
        </footer>
    </div>

<script type="text/javascript">
    $(function() {
        $('#show_add_live').click(function() {
            $('#live_add_container').show();
        });
        $('#add_live_btn').click(function() {
            var live_path = $('#live_path').val();
            var live_liveno = $('#live_liveno').val();
            var data = {
                path: live_path,
                liveno: live_liveno,
            }
            $.ajax({
                type: "POST", url: "/admin/live/webSrsAdd", data: JSON.stringify(data),
                contentType: 'application/json', dataType: 'json',
                success: function(data) {
                    console.log("Got answer: ", data);
                    if (data.code == 200) {
                        window.location.reload();
                        return;
                    } else {
                        alert(data.message);
                    }
                },
                error: function() {
                    alert('操作失败');
                },
            });
        });
    });
</script>
</body>

</html>